package com.heima.controller;


import com.heima.pojo.TbVendingMachine;
import com.heima.pojo.dto.TbVendingMachineDto;
import com.heima.pojo.vo.PageResponse;
import com.heima.pojo.vo.TbVendingMachineVo;
import com.heima.service.ITbVendingMachineService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author AkiRinko
 * @since 2024-06-08
 */
@RestController
@RequestMapping("/api/vm-service/vm")
@RequiredArgsConstructor
public class TbVendingMachineController {
    private final ITbVendingMachineService tbVendingMachineService;

    /**
     * 设备搜索
     *
     * @param pageIndex
     * @param pageSize
     * @param innerCode
     * @return
     */
    @GetMapping("/search")
    private PageResponse<TbVendingMachineVo> selectVm(@RequestParam(value = "pageIndex", required = false, defaultValue = "1") Integer pageIndex,
                                                      @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                                      @RequestParam(value = "innerCode", required = false) String innerCode) {
        return tbVendingMachineService.selectVm(pageIndex, pageSize, innerCode);
    }

    @PostMapping
    private void insertVm(@RequestBody TbVendingMachineDto dto) {
        tbVendingMachineService.insertVm(dto);
    }
}
